package com.jiangwz.springbootjwt.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jiangwz.springbootjwt.util.JwtUtils;

/**
 * @author jiangwz
 * @create 2019/10/24.
 */

@RestController
public class AuthController {

    @Autowired
    private JwtUtils jwt;

    @PostMapping("/login")
    public Object login(Long userId){
        String token = jwt.generateToken(userId);
        Map<String, Object> map = new HashMap<>();
        map.put("token", token);
        map.put("expire", jwt.getExpire());
        return map;
    }
}
